home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / sys / scsi.h < prev    next >
C/C++ Source or Header  |  1991-06-27  |  29KB  |  780 lines

  1. /*
  2.  * scsi.h --
  3.  *
  4.  *    Common declarations for SCSI command formaters. This file only covers
  5.  *    definitions pertaining to the SCSI common command set that are
  6.  *    common to all SCSI device types (ie disk, tapes, WORM, printers, etc).
  7.  *    Device sepecific command format can be found in scsi{Disk,Tape,WORM}.h
  8.  *    SCSI protocol releated declarations can be found in scsiHBA.h.
  9.  *    Definitions for the SCSI device sub-system. Some of the following
  10.  *      references from the proceedings of the 1984 Mini/Micro Northeast
  11.  *    Conference might be useful in understanding SCSI. 
  12.  *
  13.  *
  14.  * Copyright 1988 Regents of the University of California
  15.  * Permission to use, copy, modify, and distribute this
  16.  * software and its documentation for any purpose and without
  17.  * fee is hereby granted, provided that the above copyright
  18.  * notice appear in all copies.  The University of California
  19.  * makes no representations about the suitability of this
  20.  * software for any purpose.  It is provided "as is" without
  21.  * express or implied warranty.
  22.  *
  23.  * $Header: /sprite/src/lib/include/sys/RCS/scsi.h,v 1.1 91/06/25 15:20:22 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  24.  */
  25.  
  26. #ifndef _SCSI_H
  27. #define _SCSI_H
  28.  
  29. #include <machparam.h>
  30.  
  31. #ifndef BYTE_ORDER
  32. BYTE_ORDER is not defined
  33. #endif
  34. /*
  35.  * "Standard" SCSI Commands. SCSI command are divided into 8 group as
  36.  * follows:
  37.  *    Group0    (0x00 - 0x1f).  Basic commands. 6 bytes long
  38.  *    Group1    (0x20 - 0x3f).  Extended command. 10 bytes.
  39.  *    Group2    (0x40 - 0x5f).    Reserved.
  40.  *    Group2    (0x60 - 0x7f).    Reserved.
  41.  *    Group2    (0x80 - 0x9f).    Reserved.
  42.  *    Group2    (0xa0 - 0xbf).    Reserved.
  43.  *    Group6    (0xc0 - 0xdf).    Vendor Unique
  44.  *    Group7    (0xe0 - 0xff).  Vendor Unique
  45.  *    
  46.  *
  47.  */
  48.  
  49. /*
  50.  * Scsi Group0 commands all are 6 bytes and have a format according to 
  51.  * struct ScsiGroup0Cmd.
  52.  */
  53.  
  54. #define SCSI_TEST_UNIT_READY    0x00
  55. #define SCSI_REZERO_UNIT    0x01
  56. #define SCSI_REQUEST_SENSE    0x03
  57. #define    SCSI_FORMAT_UNIT    0x04
  58. #define SCSI_REASSIGN_BLOCKS    0x07
  59. #define SCSI_READ        0x08
  60. #define SCSI_WRITE        0x0a
  61. #define SCSI_SEEK        0x0b
  62. #define SCSI_INQUIRY        0x12
  63. #define SCSI_MODE_SELECT    0x15
  64. #define    SCSI_RESERVE_UNIT    0x16
  65. #define    SCSI_RELEASE_UNIT    0x17
  66. #define SCSI_COPY        0x18
  67. #define SCSI_MODE_SENSE        0x1A
  68. #define SCSI_START_STOP        0x1b
  69. #define    SCSI_RECV_DIAG_RESULTS    0x1c
  70. #define SCSI_SEND_DIAGNOSTIC    0x1d
  71. #define SCSI_PREVENT_ALLOW     0x1e
  72. /*
  73.  * Group1 commands are all 10 bytes and have a format according to
  74.  * struct ScsiGroup1Cmd.
  75.  */
  76. #define SCSI_READ_CAPACITY     0x25    
  77. #define    SCSI_READ_EXT        0x28
  78. #define    SCSI_WRITE_EXT        0x2a
  79. #define    SCSI_SEEK_EXT        0x2b
  80. #define    SCSI_WRITE_VERIFY    0x2e
  81. #define    SCSI_VERIFY_EXT        0x2f
  82. #define    SCSI_SEARCH_HIGH    0x30
  83. #define SCSI_SEARCH_EQUAL    0x31
  84. #define    SCSI_SEARCH_LOW        0x32
  85. #define    SCSI_SET_LIMITS        0x33
  86. #define    SCSI_COMPARE        0x39
  87. #define    SCSI_COPY_VERIFY    0x3a
  88.  
  89.  
  90. /*
  91.  * Group-0 commands for sequential access devices.
  92.  */
  93.  
  94. #define SCSI_REWIND        0x01
  95. #define SCSI_READ_BLOCK_LIMITS    0x05
  96. #define    SCSI_TRACK_SELECT    0x0b
  97. #define    SCSI_READ_REVERSE    0x0f
  98. #define SCSI_WRITE_EOF        0x10
  99. #define SCSI_SPACE        0x11
  100. #define    SCSI_VERIFY        0x13
  101. #define    SCSI_READ_BUFFER    0x14
  102. #define SCSI_ERASE_TAPE        0x19
  103. #define    SCSI_LOAD_UNLOAD    0x1b
  104.  
  105. /*
  106.  * Group-1 commands for sequential access devices.
  107.  */
  108. #define SCSI_LOCATE        0x2b
  109. #define SCSI_READ_POSITION    0x34
  110.  
  111.  
  112. /*
  113.  * The standard group-0 6-byte SCSI control block.  Note that the 
  114.  * fields between highAddr and blockCount inclusive are command dependent.
  115.  * The definitions Addr and BlockCount cover most of the commands we will
  116.  * use.
  117.  */
  118.  
  119. typedef struct ScsiGroup0Cmd {
  120. #if BYTE_ORDER == BIG_ENDIAN
  121.     unsigned char command;        /* command code, defined below.  The
  122.                      * upper three bits of this are zero
  123.                      * to indicate the control block is
  124.                      * only 6 bytes long */
  125.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  126.                      * pass the command.  The device
  127.                      * has already been selected using
  128.                      * the "targetID" bit. */
  129.     unsigned char highAddr    :5;    /* High bits of address */
  130.     unsigned char midAddr;        /* Middle bits of address */
  131.     unsigned char lowAddr;        /* Low bits of address */
  132.     unsigned char blockCount;        /* Blocks to transfer */
  133.     unsigned char vendor57    :1;    /* Vendor unique bit */
  134.     unsigned char vendor56    :1;    /* Vendor unique bit */
  135.     unsigned char pad1        :4;    /* Reserved */
  136.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  137.     unsigned char link        :1;    /* Another command follows */
  138. #else
  139.     unsigned char command;        /* command code, defined below.  The
  140.                      * upper three bits of this are zero
  141.                      * to indicate the control block is
  142.                      * only 6 bytes long */
  143.     unsigned char highAddr    :5;    /* High bits of address */
  144.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  145.                      * pass the command.  The device
  146.                      * has already been selected using
  147.                      * the "targetID" bit. */
  148.     unsigned char midAddr;        /* Middle bits of address */
  149.     unsigned char lowAddr;        /* Low bits of address */
  150.     unsigned char blockCount;        /* Blocks to transfer */
  151.     unsigned char link        :1;        /* Another command follows */
  152.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  153.     unsigned char pad1        :4;    /* Reserved */
  154.     unsigned char vendor56    :1;    /* Vendor unique bit */
  155.     unsigned char vendor57    :1;    /* Vendor unique bit */
  156. #endif
  157. } ScsiGroup0Cmd;
  158.  
  159. /*
  160.  * SCSI status completion information.  This is returned by the device
  161.  * when a command completes. 
  162.  */
  163.  
  164. typedef struct ScsiStatus {
  165. #if BYTE_ORDER == BIG_ENDIAN
  166.     unsigned char reserved    :1;    /* Reserved. */
  167.     unsigned char vendor06    :1;    /* Vendor unique bit */
  168.     unsigned char vendor05    :1;    /* Vendor unique bit */
  169.     unsigned char intStatus    :1;    /* Intermediate status */
  170.     unsigned char busy        :1;    /* Device busy or reserved */
  171.     unsigned char conditionMet    :1;    /* Condition met */
  172.     unsigned char check        :1;    /* Check the sense data for more info */
  173.     unsigned char vendor00    :1;    /* Vendor unique bit */
  174. #else
  175.     unsigned char vendor00    :1;    /* Vendor unique bit */
  176.     unsigned char check        :1;    /* Check the sense data for more info */
  177.     unsigned char conditionMet    :1;    /* Condition met */
  178.     unsigned char busy        :1;    /* Device busy or reserved */
  179.     unsigned char intStatus    :1;    /* Intermediate status */
  180.     unsigned char vendor05    :1;    /* Vendor unique bit */
  181.     unsigned char vendor06    :1;    /* Vendor unique bit */
  182.     unsigned char reserved    :1;    /* Reserved. */
  183. #endif
  184. } ScsiStatus;
  185.  
  186. /*
  187.  * SCSI_RESERVED_STATUS() - Return TRUE if the status byte has a reserved code.
  188.  */
  189.  
  190. #define    SCSI_RESERVED_STATUS(byte) (byte&0x80)
  191.  
  192.  
  193. /*
  194.  * Sense information provided after some errors.  This is divided into
  195.  * two kinds, classes 0-6, and class 7.  This is 30 bytes big to allow
  196.  * for the drive specific sense bytes that follow the standard 4 byte header.
  197.  *
  198.  * For extended sense, this buffer may be cast into another type.  Also
  199.  * The actual size of the sense data returned is used to detect what
  200.  * kind of tape drive is out there.  Kludgy, but true.
  201.  */
  202. typedef struct ScsiClass0Sense {
  203. #if BYTE_ORDER == BIG_ENDIAN
  204.     unsigned char valid        :1;    /* Sense data is valid */
  205.     unsigned char error        :7;    /* 3 bits class and 4 bits code */
  206.     unsigned char highAddr;        /* High byte of block address */
  207.     unsigned char midAddr;        /* Middle byte of block address */
  208.     unsigned char lowAddr;        /* Low byte of block address */
  209.     unsigned char sense[26];        /* Target specific sense data */
  210. #else
  211.     unsigned char error        :7;    /* 3 bits class and 4 bits code */
  212.     unsigned char valid        :1;    /* Sense data is valid */
  213.     unsigned char highAddr;        /* High byte of block address */
  214.     unsigned char midAddr;        /* Middle byte of block address */
  215.     unsigned char lowAddr;        /* Low byte of block address */
  216.     unsigned char sense[26];        /* Target specific sense data */
  217. #endif
  218. } ScsiClass0Sense;
  219.  
  220. /*
  221.  * Definitions for errors in the sense data.  The error field is specified
  222.  * as a 3 bit class and 4 bit code, but it is easier to treat it as a
  223.  * single 7 bit field.
  224.  */
  225. #define SCSI_NO_SENSE_DATA        0x00
  226. #define SCSI_NOT_READY            0x04
  227. #define SCSI_NOT_LOADED            0x09
  228. #define SCSI_INSUF_CAPACITY        0x0a
  229. #define SCSI_HARD_DATA_ERROR        0x11
  230. #define SCSI_WRITE_PROTECT        0x17
  231. #define SCSI_CORRECTABLE_ERROR        0x18
  232. #define SCSI_FILE_MARK            0x1c
  233. #define SCSI_INVALID_COMMAND        0x20
  234. #define SCSI_UNIT_ATTENTION        0x30
  235. #define SCSI_END_OF_MEDIA        0x34
  236.  
  237. /*
  238.  * The standard "extended" sense data returned by SCSI devices.  This
  239.  * has an error field of 0x70, for a "class 7" error.
  240.  */
  241. typedef struct ScsiClass7Sense {
  242. #if BYTE_ORDER == BIG_ENDIAN
  243.     unsigned char valid        :1;    /* Sense data is valid */
  244.     unsigned char error7    :7;    /* == 0x70 */
  245.     unsigned char pad1;            /* Also "segment number" for copy */
  246.     unsigned char fileMark    :1;    /* File mark on device */
  247.     unsigned char endOfMedia    :1;    /* End of media reached */
  248.     unsigned char badBlockLen    :1;    /* Block length mis-match (Exabyte) */
  249.     unsigned char pad2        :1;
  250.     unsigned char key        :4;    /* Sense keys defined below */
  251.     unsigned char info1;        /* Information byte 1 */
  252.     unsigned char info2;        /* Information byte 2 */
  253.     unsigned char info3;        /* Information byte 3 */
  254.     unsigned char info4;        /* Information byte 4 */
  255.     unsigned char length;        /* Number of additional info bytes */
  256. #else
  257.     unsigned char error7    :7;    /* == 0x70 */
  258.     unsigned char valid        :1;    /* Sense data is valid */
  259.     unsigned char pad1;            /* Also "segment number" for copy */
  260.     unsigned char key        :4;    /* Sense keys defined below */
  261.     unsigned char pad2        :1;
  262.     unsigned char badBlockLen    :1;    /* Block length mis-match (Exabyte) */
  263.     unsigned char endOfMedia    :1;    /* End of media reached */
  264.     unsigned char fileMark    :1;    /* File mark on device */
  265.     unsigned char info1;        /* Information byte 1 */
  266.     unsigned char info2;        /* Information byte 2 */
  267.     unsigned char info3;        /* Information byte 3 */
  268.     unsigned char info4;        /* Information byte 4 */
  269.     unsigned char length;        /* Number of additional info bytes */
  270. #endif
  271. } ScsiClass7Sense;            /* 8 Bytes */
  272.  
  273. /*
  274.  * Key values for standardized sense class 7. 
  275.  */
  276. #define SCSI_CLASS7_NO_SENSE        0
  277. #define SCSI_CLASS7_RECOVERABLE    1
  278. #define SCSI_CLASS7_NOT_READY        2
  279. #define SCSI_CLASS7_MEDIA_ERROR    3
  280. #define SCSI_CLASS7_HARDWARE_ERROR    4
  281. #define SCSI_CLASS7_ILLEGAL_REQUEST    5
  282.  
  283. /*
  284.  * These seem to have different meanings to different vendors....
  285.  */
  286. #define SCSI_CLASS7_MEDIA_CHANGE    6
  287. #define SCSI_CLASS7_UNIT_ATTN        6
  288.  
  289. #define SCSI_CLASS7_WRITE_PROTECT    7
  290. #define SCSI_CLASS7_BLANK_CHECK        8
  291. #define SCSI_CLASS7_VENDOR        9
  292. #define SCSI_CLASS7_POWER_UP_FAILURE    10
  293. #define SCSI_CLASS7_ABORT        11
  294. #define SCSI_CLASS7_EQUAL        12
  295. #define SCSI_CLASS7_OVERFLOW        13
  296. #define SCSI_CLASS7_RESERVED_14        14
  297. #define SCSI_CLASS7_RESERVED_15        15
  298.  
  299. /*
  300.  * Maximum size of sense data that a device can return. XXX - fix this.
  301.  */
  302. #define    SCSI_MAX_SENSE_LEN    64
  303.  
  304. /*
  305.  * Data return by the SCSI inquiry command. 
  306.  */
  307.  
  308. typedef struct ScsiInquiryData {
  309. #if BYTE_ORDER == BIG_ENDIAN
  310.     unsigned char     type;        /* Peripheral Device type. See below. */
  311.     unsigned char     rmb:1;        /* Removable Medium bit. */
  312.     unsigned char    qualifier:7;     /* Device type qualifier. */
  313.     unsigned char    version;    /* Version info. */
  314.     unsigned char    reserved:4;    /* reserved. */
  315.     unsigned char    format:4;    /* Response format. */
  316.     unsigned char    length;        /* length of data returned. */
  317. #ifdef notdef
  318.     unsigned char    vendor;        /* Vendor unqiue parameter. */
  319.     unsigned char    reserved2[2];    /* More reserved. */
  320.     char        vendorInfo[8];    /* Vector identification. */
  321.     char        productInfo[8]; /* Product identification. */
  322.     char        firmwareInfo[4]; /* Firmware identification. */
  323. #endif
  324.  
  325.     unsigned char    reserved2[3];    /* Reserved                  */
  326.     unsigned char    vendorID[8];    /* Vendor ID (ASCII)              */
  327.     unsigned char    productID[16];    /* Product ID (ASCII)              */
  328.     unsigned char    revLevel[4];    /* Revision level (ASCII)          */
  329.     unsigned char    revData[8];    /* Revision data (ASCII)          */
  330. #else
  331.     unsigned char     type;        /* Peripheral Device type. See below. */
  332.     unsigned char    qualifier:7;     /* Device type qualifier. */
  333.     unsigned char     rmb:1;        /* Removable Medium bit. */
  334.     unsigned char    version;    /* Version info. */
  335.     unsigned char    format:4;    /* Response format. */
  336.     unsigned char    reserved:4;    /* reserved. */
  337.     unsigned char    length;        /* length of data returned. */
  338.     unsigned char    reserved2[3];    /* Reserved                  */
  339.     unsigned char    vendorID[8];    /* Vendor ID (ASCII)              */
  340.     unsigned char    productID[16];    /* Product ID (ASCII)              */
  341.     unsigned char    revLevel[4];    /* Revision level (ASCII)          */
  342.     unsigned char    revData[8];    /* Revision data (ASCII)          */
  343. #endif
  344. }  ScsiInquiryData;
  345.  
  346.  
  347. /*
  348.  * The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command.
  349.  *
  350.  * SCSI_DISK_TYPE - Direct Access Device.
  351.  * SCSI_TAPE_TYPE - Sequential Access Device.
  352.  * SCSI_PRINTER_TYPE - Printer Device.
  353.  * SCSI_HOST_TYPE - Processor Device.
  354.  * SCSI_WORM_TYPE - Write-Once Read-Multiple Device.
  355.  * SCSI_ROM_TYPE  - Read-Only Direct Access Device.
  356.  * SCSI_SCANNER_TYPE - Scanner device.
  357.  * SCSI_OPTICAL_MEM_TYPE - Optical memory device.
  358.  * SCSI_MEDIUM_CHANGER_TYPE - Medium changer device.
  359.  * SCSI_COMMUNICATIONS_TYPE - Communications device.
  360.  * SCSI_NODEVICE_TYPE - Logical Unit not present or implemented.
  361.  *
  362.  * Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique.
  363.  */
  364. #define    SCSI_DISK_TYPE        0
  365. #define    SCSI_TAPE_TYPE        1
  366. #define    SCSI_PRINTER_TYPE    2
  367. #define    SCSI_HOST_TYPE        3
  368. #define    SCSI_WORM_TYPE        4
  369. #define    SCSI_ROM_TYPE        5
  370. #define    SCSI_SCANNER_TYPE    6
  371. #define    SCSI_OPTICAL_MEM_TYPE    7
  372. #define    SCSI_MEDIUM_CHANGER_TYPE    8
  373. #define    SCSI_COMMUNICATIONS_TYPE    9
  374. #define    SCSI_NODEVICE_TYPE    0x7f
  375.  
  376. /*
  377.  * Standard header for SCSI_MODE_SELECT commands for tapes.
  378.  */
  379.  
  380. typedef struct ScsiTapeModeSelectHdr {
  381. #if BYTE_ORDER == BIG_ENDIAN
  382.     unsigned char    reserved[2];    /* Reserved. */
  383.     unsigned char    reserved2:1;    /*  ""         */
  384.     unsigned char    bufferedMode:3;    /* Type of buffer to be done. */
  385.     unsigned char    speed:4;    /* Drive speed. */
  386.     unsigned char    length;        /* Block descriptor length. */
  387. #else
  388.     unsigned char    reserved[2];    /* Reserved. */
  389.     unsigned char    speed:4;    /* Drive speed. */
  390.     unsigned char    bufferedMode:3;    /* Type of buffer to be done. */
  391.     unsigned char    reserved2:1;    /*  ""         */
  392.     unsigned char    length;        /* Block descriptor length. */
  393. #endif
  394. } ScsiTapeModeSelectHdr;
  395. /*
  396.  * Format of a SCSI_START_STOP command. This is a group 0 command, but
  397.  * the command contents are different.
  398.  */
  399. typedef struct ScsiStartStopCmd {
  400. #if BYTE_ORDER == BIG_ENDIAN
  401.     unsigned char command;        /* 0x1b */
  402.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  403.                      * pass the command.  The device
  404.                      * has already been selected using
  405.                      * the "targetID" bit. */
  406.     unsigned char pad1        :4;    /* Reserved */
  407.     unsigned char immed        :1;    /* Immediate status bit */
  408.     unsigned char pad2;            /* Reserved */
  409.     unsigned char pad3;            /* Reserved */
  410.     unsigned char pad4        :6;    /* Reserved */
  411.     unsigned char loadEject    :1;    /* Load or eject medium */
  412.     unsigned char start        :1;    /* Start or stop medium */
  413.     unsigned char vendor57    :1;    /* Vendor unique bit */
  414.     unsigned char vendor56    :1;    /* Vendor unique bit */
  415.     unsigned char pad5        :4;    /* Reserved */
  416.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  417.     unsigned char link        :1;    /* Another command follows */
  418. #else
  419.     unsigned char command;        /* command code, defined below.  The
  420.                      * upper three bits of this are zero
  421.                      * to indicate the control block is
  422.                      * only 6 bytes long */
  423.     unsigned char immed        :1;    /* Immediate status bit */
  424.     unsigned char pad1        :4;    /* Reserved */
  425.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  426.                      * pass the command.  The device
  427.                      * has already been selected using
  428.                      * the "targetID" bit. */
  429.     unsigned char pad2;            /* Reserved */
  430.     unsigned char pad3;            /* Reserved */
  431.     unsigned char start        :1;    /* Start or stop medium */
  432.     unsigned char loadEject    :1;    /* Load or eject medium */
  433.     unsigned char pad4        :6;    /* Reserved */
  434.     unsigned char link        :1;    /* Another command follows */
  435.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  436.     unsigned char pad5        :4;    /* Reserved */
  437.     unsigned char vendor56    :1;    /* Vendor unique bit */
  438.     unsigned char vendor57    :1;    /* Vendor unique bit */
  439. #endif
  440. } ScsiStartStopCmd;
  441.  
  442.  
  443. /*
  444.  * Format of a SCSI_READ_EXT command.
  445.  */
  446.  
  447. typedef struct ScsiReadExtCmd {
  448. #if BYTE_ORDER == BIG_ENDIAN
  449.     unsigned char command;        /* command code. */
  450.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  451.                      * pass the command.  The device
  452.                      * has already been selected using
  453.                      * the "targetID" bit. */
  454.     unsigned char dpo        :1;    /* Disable page out. */
  455.     unsigned char fua        :1;    /* Force unit access. */
  456.     unsigned char pad1        :2;    /* Reserved. */
  457.     unsigned char relAddr    :1;    /* Who knows? */
  458.     unsigned char highAddr;        /* High bits of address. */
  459.     unsigned char highMidAddr;        /* High middle bits of address. */
  460.     unsigned char lowMidAddr;        /* Low middle bits of address. */
  461.     unsigned char lowAddr;        /* Low bits of address */
  462.     unsigned char pad2;            /* Reserved. */
  463.     unsigned char highCount;        /* High bits of number to transfer */
  464.     unsigned char lowCount;        /* Low bits of number to transfer */
  465.     unsigned char vendor    :2;    /* Vendor specific. */
  466.     unsigned char pad        :4;    /* Reserved. */
  467.     unsigned char flag        :1;    /* Flag bit. See SCSI doc. */
  468.     unsigned char link        :1;    /* Link commands. */
  469. #else
  470.     unsigned char command;        /* command code. */
  471.     unsigned char relAddr    :1;    /* Who knows? */
  472.     unsigned char pad1        :2;    /* Reserved. */
  473.     unsigned char fua        :1;    /* Force unit access. */
  474.     unsigned char dpo        :1;    /* Disable page out. */
  475.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  476.                      * pass the command.  The device
  477.                      * has already been selected using
  478.                      * the "targetID" bit. */
  479.     unsigned char highAddr;        /* High bits of address. */
  480.     unsigned char highMidAddr;        /* High middle bits of address. */
  481.     unsigned char lowMidAddr;        /* Low middle bits of address. */
  482.     unsigned char lowAddr;        /* Low bits of address */
  483.     unsigned char pad2;            /* Reserved. */
  484.     unsigned char highCount;        /* High bits of number to transfer */
  485.     unsigned char lowCount;        /* Low bits of number to transfer */
  486.     unsigned char link        :1;    /* Link commands. */
  487.     unsigned char flag        :1;    /* Flag bit. See SCSI doc. */
  488.     unsigned char pad        :4;    /* Reserved. */
  489.     unsigned char vendor    :2;    /* Vendor specific. */
  490. #endif
  491. } ScsiReadExtCmd;
  492.  
  493. /*
  494.  * The SCSI_WRITE_EXT command had the same format as SCSI_READ_EXT.
  495.  */
  496.  
  497. typedef struct ScsiReadExtCmd ScsiWriteExtCmd;
  498.  
  499. /* 
  500.  * Data returned by the SCSI_READ_BLOCK_LIMITS command.
  501.  */
  502.  
  503. typedef struct {
  504.     unsigned char    pad1;
  505.     unsigned char    max2;    /* MSB of max block size. */
  506.     unsigned char    max1;    /* ... */
  507.     unsigned char    max0;    /* LSB of max block size. */
  508.     unsigned char    min1;    /* MSB of min block size. */
  509.     unsigned char    min0;    /* LSB of min block size. */
  510. } ScsiBlockLimits;
  511.  
  512. /*
  513.  * Format of a SCSI_MODE_SENSE command. 
  514.  */
  515. typedef struct {
  516. #if BYTE_ORDER == BIG_ENDIAN
  517.     unsigned char command;        /* 0x1b */
  518.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  519.                      * pass the command.  The device
  520.                      * has already been selected using
  521.                      * the "targetID" bit. */
  522.     unsigned char pad1        :1;    /* Reserved */
  523.     unsigned char disableBlockDesc :1;    /* Disable block descriptor */
  524.     unsigned char pad2        :3;    /* Reserved */
  525.     unsigned char pageControl    :2;    /* Page Control */
  526.     unsigned char pageCode    :6;    /* Page Code */
  527.     unsigned char pad3;            /* Reserved */
  528.     unsigned char allocLen;        /* Allocation length. */
  529.     unsigned char vendor    :2;    /* Vendor unique. */
  530.     unsigned char pad4        :6;    /* Reserved */
  531. #else
  532.     unsigned char command;        /* 0x1b */
  533.     unsigned char pad2        :3;    /* Reserved */
  534.     unsigned char disableBlockDesc :1;    /* Disable block descriptor */
  535.     unsigned char pad1        :1;    /* Reserved */
  536.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  537.                      * pass the command.  The device
  538.                      * has already been selected using
  539.                      * the "targetID" bit. */
  540.     unsigned char pageCode    :6;    /* Page Code */
  541.     unsigned char pageControl    :2;    /* Page Control */
  542.     unsigned char pad3;            /* Reserved */
  543.     unsigned char allocLen;        /* Allocation length. */
  544.     unsigned char pad4        :6;    /* Reserved */
  545.     unsigned char vendor    :2;    /* Vendor unique. */
  546. #endif
  547. } ScsiModeSenseCmd;
  548.  
  549. /*
  550.  * Block descriptor returned by mode sense.
  551.  */
  552.  
  553. typedef struct {
  554.     unsigned char    density;    /* Density code. */
  555.     unsigned char    num2;        /* MSB of number of blocks. */
  556.     unsigned char    num1;        /* ... */
  557.     unsigned char    num0;        /* LSB of number of blocks. */
  558.     unsigned char    pad0;        /* Reserved. */
  559.     unsigned char    len2;        /* MSB of block length. */
  560.     unsigned char    len1;        /* ... */
  561.     unsigned char    len0;        /* LSB of block length. */
  562. } ScsiBlockDesc;
  563.  
  564. /*
  565.  * Format of a SCSI_REQUEST_SENSE command.
  566.  */
  567. typedef struct {
  568. #if BYTE_ORDER == BIG_ENDIAN
  569.     unsigned char command;        /* 0x1b */
  570.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  571.                      * pass the command.  The device
  572.                      * has already been selected using
  573.                      * the "targetID" bit. */
  574.     unsigned char pad1        :5;    /* Reserved */
  575.     unsigned char pad2;            /* Reserved */
  576.     unsigned char pad3;            /* Reserved */
  577.     unsigned char allocLen;        /* Allocation length. */
  578.     unsigned char clearCount    :1;    /* Clear counters. */
  579.     unsigned char vendor    :1;    /* Vendor unique. */
  580.     unsigned char pad4        :6;    /* Reserved */
  581. #else
  582.     unsigned char command;        /* 0x1b */
  583.     unsigned char pad1        :5;    /* Reserved */
  584.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  585.                      * pass the command.  The device
  586.                      * has already been selected using
  587.                      * the "targetID" bit. */
  588.     unsigned char pad2;            /* Reserved */
  589.     unsigned char pad3;            /* Reserved */
  590.     unsigned char allocLen;        /* Allocation length. */
  591.     unsigned char pad4        :6;    /* Reserved */
  592.     unsigned char vendor    :1;    /* Vendor unique. */
  593.     unsigned char clearCount    :1;    /* Clear counters. */
  594. #endif
  595. } ScsiRequestSenseCmd;
  596.  
  597. /*
  598.  * Format of a SCSI_READ_POSITION command.
  599.  */
  600.  
  601. typedef struct {
  602. #if BYTE_ORDER == BIG_ENDIAN
  603.     unsigned char command;        /* 0x34 */
  604.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  605.                      * pass the command.  The device
  606.                      * has already been selected using
  607.                      * the "targetID" bit. */
  608.     unsigned char pad1        :4;    /* Reserved */
  609.     unsigned char blockType    :1;    /* Block type. */
  610.     unsigned char pad2;            /* Reserved */
  611.     unsigned char pad3;            /* Reserved */
  612.     unsigned char pad4;            /* Reserved */
  613.     unsigned char pad5;            /* Reserved */
  614.     unsigned char pad6;            /* Reserved */
  615.     unsigned char pad7;            /* Reserved */
  616.     unsigned char pad8;            /* Reserved */
  617.     unsigned char vendor    :2;    /* Vendor unique. */
  618.     unsigned char pad9        :6;    /* Reserved */
  619. #else
  620.     unsigned char command;        /* 0x34 */
  621.     unsigned char blockType    :1;    /* Block type. */
  622.     unsigned char pad1        :4;    /* Reserved */
  623.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  624.                      * pass the command.  The device
  625.                      * has already been selected using
  626.                      * the "targetID" bit. */
  627.     unsigned char pad2;            /* Reserved */
  628.     unsigned char pad3;            /* Reserved */
  629.     unsigned char pad4;            /* Reserved */
  630.     unsigned char pad5;            /* Reserved */
  631.     unsigned char pad6;            /* Reserved */
  632.     unsigned char pad7;            /* Reserved */
  633.     unsigned char pad8;            /* Reserved */
  634.     unsigned char pad9        :6;    /* Reserved */
  635.     unsigned char vendor    :2;    /* Vendor unique. */
  636. #endif
  637. } ScsiReadPositionCmd;
  638.  
  639. /*
  640.  * Result of a SCSI_READ_POSITION command.
  641.  */
  642.  
  643. typedef struct {
  644. #if BYTE_ORDER == BIG_ENDIAN
  645.     unsigned char bop        :1;    /* Beginning of partition. */
  646.     unsigned char eop        :1;    /* End of partition. */
  647.     unsigned char pad0a        :3;    /* Reserved. */
  648.     unsigned char bpu        :1;    /* Block position unknown. */
  649.     unsigned char pad0b        :2;    /* Reserved. */
  650.     unsigned char partition;        /* Partition number. */
  651.     unsigned char pad2;            /* Reserved. */
  652.     unsigned char pad3;            /* Reserved. */
  653.     unsigned char firstBlock3;        /* First block location, MSB */
  654.     unsigned char firstBlock2;        /* ... */
  655.     unsigned char firstBlock1;        /* ... */
  656.     unsigned char firstBlock0;        /* First block location, LSB */
  657.     unsigned char lastBlock3;        /* Last block location, MSB */
  658.     unsigned char lastBlock2;        /* ... */
  659.     unsigned char lastBlock1;        /* ... */
  660.     unsigned char lastBlock0;        /* Last block location, LSB */
  661.     unsigned char pad12;        /* Reserved. */
  662.     unsigned char blocksInBuf2;        /* Blocks in buffer, MSB. */
  663.     unsigned char blocksInBuf1;        /* ... */
  664.     unsigned char blocksInBuf0;        /* Blocks in buffer, LSB. */
  665.     unsigned char bytesInBuf3;        /* Bytes in buffer, MSB. */
  666.     unsigned char bytesInBuf2;        /* ... */
  667.     unsigned char bytesInBuf1;        /* ... */
  668.     unsigned char bytesInBuf0;        /* Bytes in buffer, LSB. */
  669. #else
  670.     unsigned char pad0b        :2;    /* Reserved. */
  671.     unsigned char bpu        :1;    /* Block position unknown. */
  672.     unsigned char pad0a        :3;    /* Reserved. */
  673.     unsigned char eop        :1;    /* End of partition. */
  674.     unsigned char bop        :1;    /* Beginning of partition. */
  675.     unsigned char partition;        /* Partition number. */
  676.     unsigned char pad2;            /* Reserved. */
  677.     unsigned char pad3;            /* Reserved. */
  678.     unsigned char firstBlock3;        /* First block location, MSB */
  679.     unsigned char firstBlock2;        /* ... */
  680.     unsigned char firstBlock1;        /* ... */
  681.     unsigned char firstBlock0;        /* First block location, LSB */
  682.     unsigned char lastBlock3;        /* Last block location, MSB */
  683.     unsigned char lastBlock2;        /* ... */
  684.     unsigned char lastBlock1;        /* ... */
  685.     unsigned char lastBlock0;        /* Last block location, LSB */
  686.     unsigned char pad12;        /* Reserved. */
  687.     unsigned char blocksInBuf2;        /* Blocks in buffer, MSB. */
  688.     unsigned char blocksInBuf1;        /* ... */
  689.     unsigned char blocksInBuf0;        /* Blocks in buffer, LSB. */
  690.     unsigned char bytesInBuf3;        /* Bytes in buffer, MSB. */
  691.     unsigned char bytesInBuf2;        /* ... */
  692.     unsigned char bytesInBuf1;        /* ... */
  693.     unsigned char bytesInBuf0;        /* Bytes in buffer, LSB. */
  694. #endif
  695. } ScsiReadPositionResult;
  696.  
  697. /*
  698.  * Format of SCSI_LOCATE command.
  699.  */
  700.  
  701. typedef struct {
  702. #if BYTE_ORDER == BIG_ENDIAN
  703.     unsigned char command;        /* 0x2b */
  704.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  705.                      * pass the command.  The device
  706.                      * has already been selected using
  707.                      * the "targetID" bit. */
  708.     unsigned char pad1        :2;    /* Reserved */
  709.     unsigned char blockType    :1;    /* Block type. */
  710.     unsigned char changePartition :1;    /* Change partitions. */
  711.     unsigned char immediate    :1;    /* Immediate. */
  712.     unsigned char pad2;            /* Reserved */
  713.     unsigned char addr3;        /* Block address, MSB */
  714.     unsigned char addr2;        /* ... */
  715.     unsigned char addr1;        /* ... */
  716.     unsigned char addr0;        /* Block address, LSB */
  717.     unsigned char pad7;            /* Reserved */
  718.     unsigned char partition;        /* Partition */
  719.     unsigned char vendor    :2;    /* Vendor unique. */
  720.     unsigned char pad9        :6;    /* Reserved */
  721. #else
  722.     unsigned char command;        /* 0x2b */
  723.     unsigned char immediate    :1;    /* Immediate. */
  724.     unsigned char changePartition :1;    /* Change partitions. */
  725.     unsigned char blockType    :1;    /* Block type. */
  726.     unsigned char pad1        :2;    /* Reserved */
  727.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  728.                      * pass the command.  The device
  729.                      * has already been selected using
  730.                      * the "targetID" bit. */
  731.     unsigned char pad2;            /* Reserved */
  732.     unsigned char addr3;        /* Block address, MSB */
  733.     unsigned char addr2;        /* ... */
  734.     unsigned char addr1;        /* ... */
  735.     unsigned char addr0;        /* Block address, LSB */
  736.     unsigned char pad7;            /* Reserved */
  737.     unsigned char partition;        /* Partition */
  738.     unsigned char pad9        :6;    /* Reserved */
  739.     unsigned char vendor    :2;    /* Vendor unique. */
  740. #endif
  741. } ScsiLocateCmd;
  742.  
  743. /*
  744.  * Format of SCSI_PREVENT_ALLOW command.
  745.  */
  746.  
  747. typedef struct {
  748. #if BYTE_ORDER == BIG_ENDIAN
  749.     unsigned char command;        /* 0x1e */
  750.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  751.                      * pass the command.  The device
  752.                      * has already been selected using
  753.                      * the "targetID" bit. */
  754.     unsigned char pad1        :5;    /* Reserved. */
  755.     unsigned char pad2;            /* Reserved. */
  756.     unsigned char pad3;            /* Reserved. */
  757.     unsigned char pad4        :7;    /* Reserved. */
  758.     unsigned char prevent    :1;    /* 0 = allow, 1 = prevent */
  759.     unsigned char vendor    :2;    /* Vendor unique. */
  760.     unsigned char pad5        :6;    /* Reserved */
  761. #else
  762.     unsigned char command;        /* 0x1e */
  763.     unsigned char pad1        :5;    /* Reserved. */
  764.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  765.                      * pass the command.  The device
  766.                      * has already been selected using
  767.                      * the "targetID" bit. */
  768.     unsigned char pad2;            /* Reserved. */
  769.     unsigned char pad3;            /* Reserved. */
  770.     unsigned char prevent    :1;    /* 0 = allow, 1 = prevent */
  771.     unsigned char pad4        :7;    /* Reserved. */
  772.     unsigned char pad5        :6;    /* Reserved */
  773.     unsigned char vendor    :2;    /* Vendor unique. */
  774. #endif
  775. } ScsiPreventAllowCmd;
  776.  
  777.  
  778.  
  779. #endif /* _SCSI_H */
  780.